//
//  AppDelegate.m
//  项目
//
//  Created by 张诗雨 on 14/12/27.
//  Copyright (c) 2014年 张诗雨. All rights reserved.
//

#import "AppDelegate.h"
#import "OneDayViewController.h"
#import "ListenViewController.h"
#import "ReadViewController.h"
#import "FindViewController.h"
#import "UserViewController.h"
#import "WebColor.h"
@interface AppDelegate ()

@end

@implementation AppDelegate
- (void)dealloc
{
    [super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    NSMutableArray *array = [NSMutableArray array];
    ///  ONEDAY
    OneDayViewController *oneVC = [[OneDayViewController alloc] init];
    UINavigationController *oneNav = [[UINavigationController alloc] initWithRootViewController:oneVC];
    [oneNav.navigationBar setBarTintColor:[WebColor skyBlue]];
    oneNav.navigationBar.translucent = NO;
    UIImage *oneImg = [[UIImage imageNamed:@"bar_oneday.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    oneVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"OneDay" image:oneImg tag:10];
    [array addObject:oneNav];
    [oneNav release];
    [oneVC release];
    /// sound
    ListenViewController * listenVC = [[ListenViewController alloc] init];
    UINavigationController *listenNav = [[UINavigationController alloc] initWithRootViewController:listenVC];
    [listenNav.navigationBar setBarTintColor:[WebColor skyBlue]];
    listenNav.navigationBar.translucent = NO;
    UIImage *listenImg = [[UIImage imageNamed:@"bar_listen.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    listenVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Sound" image:listenImg tag:20];
    [array addObject:listenNav];
    [listenNav release];
    [listenVC release];
    
    /// read
    ReadViewController *readVC = [[ReadViewController alloc] init];
    UINavigationController *readNav = [[UINavigationController alloc] initWithRootViewController:readVC];
    [readNav.navigationBar setBarTintColor:[WebColor skyBlue]];
    readNav.navigationBar.translucent = NO;
    UIImage *readImg = [[UIImage imageNamed:@"bar_read.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    readVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Read" image:readImg tag:30];
    [array addObject:readNav];
    [readNav release];
    [readVC release];
    
    /// find
    FindViewController *findVC = [[FindViewController alloc] init];
    UINavigationController *findNav = [[UINavigationController alloc] initWithRootViewController:findVC];
    [findNav.navigationBar setBarTintColor:[WebColor skyBlue]];
    findNav.navigationBar.translucent = NO;
    UIImage *findImg = [[UIImage imageNamed:@"bar_find.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    findVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Found" image:findImg tag:40];
    [array addObject:findNav];
    [findNav release];
    [findVC release];
    
    /// user
    UserViewController *userVC = [[UserViewController alloc] init];
    UINavigationController *userNav = [[UINavigationController alloc] initWithRootViewController:userVC];
    [userNav.navigationBar setBarTintColor:[WebColor skyBlue]];
    userNav.navigationBar.translucent = NO;
    UIImage *userImg = [[UIImage imageNamed:@"bar_user.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    userVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Me" image:userImg tag:50];
    [array addObject:userNav];
    [userVC release];
    [userNav release];
    
    
    UITabBarController *tabBarC = [[UITabBarController alloc] init];
    tabBarC.tabBar.translucent = NO;
    [tabBarC.tabBar setBarTintColor:[WebColor aliceBlue]];
    [tabBarC setViewControllers:array animated:YES];
    _window.rootViewController = tabBarC;
    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
